package com.css.landslide.risk.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.css.landslide.risk.entity.LandslideRisk;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

;


/**
 * @author dingling
 * @desc 滑坡危险性
 * @date 2024-09-26 16:19
 **/
@Mapper
public interface LandslideRiskMapper extends BaseMapper<LandslideRisk> {


    @Select("select st_astext(geom) as geomText, geom, id, value, file_id from data_landslide_risk")
    IPage<LandslideRisk> selectGeomText(Page<?> page);


    /**
     * 与目标相交的区域
    **/
    @Select("select st_astext(geom) as geomText, geom, id, value, file_id, " +
            "ST_Intersection(geom,#{geom,typeHandler=com.css.handler.GeometryTypeHandler}) as intersectGeom, " +
            "st_astext(ST_Intersection(geom,#{geom,typeHandler=com.css.handler.GeometryTypeHandler})) as intersectGeomText " +
            "from data_landslide_risk " +
            "where  ST_Intersects(geom, #{geom,typeHandler=com.css.handler.GeometryTypeHandler})")
    List<LandslideRisk> selectRiskLandslide(@Param("geom") String geom);
}
